<script type="text/javascript" src="__PUBLIC__/includes/javascript/jquery.validate.js" ></script>
<script type="text/javascript">
$(function(){
    $('#wx_menu_form').validate({
    	errorPlacement: function(error, element){
            $(element).next('.field_notice').hide();
            $(element).after(error);
        },
        success       : function(label){
            label.addClass('validate_right').text('OK!');
        },
        onkeyup : false,
        rules : {
        	menuName : {
        		required:true,
                maxlength:10
            },
            urlAndkey :{
            	required:true,
            	url:true
            },
            menuStort:{
            	max:127
            }
        },
        messages : {
        	menuName : {
        		required : '菜单名称不能为空。',
        		maxlength   : '菜单最多允许5个汉字。'
            },
            urlAndkey :{
            	required:'KEY值或URL不能为空，不能写#或其他字符',
            	url:"请输入正确的url格式,如 http://www.mpack.cn"
            },
            menuStort:{
            	max:'最大值为127'
            }
        }
    });
});
</script>
<ul class="tab">
    <li class="active">编辑菜单</li>
</ul>
<div class="eject_con">
 <div class="adds">
        <div id="warning"></div>
        <form id="wx_menu_form" method="post" target="_self" action="{:U('editWxMenu',array('id'=>$one_menu['id']))}">
        <ul>
            <li>
                <h3>一级菜单 :</h3>
                <p>
                <select class="J_cate_select mr10" data-pid="0" name="parent_id">
                	<option value="0">--一级菜单--{$one_menu.parentId}</option>
                	<foreach name="parentMenu" item="one_parent_menu">
                		<option value="{$one_parent_menu.id}" <if condition="$one_menu['parentId'] eq $one_parent_menu['id']">selected=selected</if> >{$one_parent_menu.menuName}</option>
                	</foreach>	
                </select>
                </p>
            </li>
            <li>
                <h3>菜单名称 :</h3>
                <p>
                <input type="text" name="menuName" id="menuName" class="text" size="15" value="{$one_menu.menuName}"><label class="field_notice"></label></p>
            </li>
            <li>
                <h3>URL或KEY:</h3>
                <p>
                	<label><input type="radio" name="menuAction" value="view"  <if condition="$one_menu.menuAction eq 'view' ">checked</if> /> VIEW</label>
               		<label><input type="radio" name="menuAction" value="click" <if condition="$one_menu.menuAction eq 'click' ">checked</if> /> CLICK</label>
               	</p>
            </li>
            <if condition="$one_menu.menuAction eq 'view'">
	            <li id="menu_view">
	                <h3>URL:</h3>
	                <p>
	                	<label><input type="text" name="url" class="text" size="25" value="{$one_menu.urlAndkey}"/></label>
	               	</p>
	            </li>
	            <li id="menu_click" style="display: none;">
	                <h3>KEY:</h3>
	                <p>
	                	<label><input type="text" name="key" value="" /></label>
	               	</p>
	            </li>
            <else />
	            <li id="menu_view" style="display: none;">
	                <h3>URL:</h3>
	                <p>
	                	<label><input type="text" name="url" class="text" size="25" value=""/></label>
	               	</p>
	            </li>
	            <li id="menu_click">
	                <h3>KEY:</h3>
	                <p>
	                	<label><input type="text" name="key" value="{$one_menu.urlAndkey}" /></label>
	               	</p>
	            </li>
            </if>
             <li>
                <h3>状态:</h3>
                <p>
                	<label><if condition="$one_menu.menuState eq '1'"><input type="radio" name="menuState" value="1" checked /><else/><input type="radio" name="menuState" value="0"></if>启用</if></label>
               		<label><if condition="$one_menu.menuState eq '0'"><input type="radio" name="menuState" value="0" checked><else/><input type="radio" name="menuState" value="0"></if> 禁用</label>
               	</p>
            </li>
             <li>
                <h3>排序:</h3>
                <p>
                	<label><input type="text" name="menuStort" value="1" class="text" size="2" value="{$one_menu.menuStort}" /></label>
               	</p>
            </li>
        </ul>
        <div class="submit"><input type="submit" class="btn" value="提交" /></div>
        </form>
    </div>
</div>
<script>
$(function(){
	$("input[name=menuAction]").click(function(){ 
		var type = $('input[name="menuAction"]:checked').val();
		if(type == "view") {
			$("#menu_view").show();
			$("#menu_click").hide();
			
		} else if(type == "click"){
			$("#menu_view").hide();
			$("#menu_click").show();
			
		}
	});
});
</script>